import { createRouter, createWebHistory } from "vue-router"

// 定义路由规则的数组
const routes = [
  // ================= 前台路由 =================
  {
    path: '/front/login',
    name: 'front_login',
    component: () => import("@/views/front/auth/LoginView.vue")
  },
  {
    path: '/front/register',
    name: 'front_register',
    component: () => import("@/views/front/auth/RegisterView.vue")
  },
  {
    path: '/front/forget',
    name: 'front_forget',
    component: () => import("@/views/front/auth/ForgetPasswordView.vue")
  },
  {
    path: '/front/layout',
    name: 'front_layout',
    component: () => import("@/views/front/layout/UserFrontLayout.vue"),
    redirect: '/front/home',
    children: [
      {
        path: '/front/home',
        name: 'front_home',
        component: () => import("@/views/front/home/HomeView.vue"),
      },
      {
        path: '/front/packages',
        name: 'front_packages',
        component: () => import("@/views/front/packages/PackagesView.vue"),
      },
      {
        path: '/front/addresses',
        name: 'front_addresses',
        component: () => import("@/views/front/addresses/AddressesView.vue"),
      },
      {
        path: '/front/order',
        name: 'front_order',
        component: () => import("@/views/front/order/OrderView.vue"),
      },
      {
        path: '/front/my',
        name: 'front_my',
        component: () => import("@/views/front/my/MyView.vue"),
      },
    ]
  },

  // ================= 后台路由 =================
  {
    path: '/admin/login',
    name: 'admin_login',
    component: () => import("@/views/admin/auth/LoginView.vue")
  },
  {
    path: '/admin/register',
    name: 'admin_register',
    component: () => import("@/views/admin/auth/RegisterView.vue")
  },
  {
    path: '/admin/forget',
    name: 'admin_forget',
    component: () => import("@/views/admin/auth/ForgetPasswordView.vue")
  },
  {
    path: '/admin/layout',
    name: 'admin_layout',
    component: () => import("@/views/admin/layout/AdminLayoutView.vue"),
    redirect: '/admin/home',
    children: [
      {
        path: '/admin/home',
        name: 'admin_home',
        component: () => import("@/views/admin/home/HomeView.vue"),
      },
      {
        path: '/admin/info',
        name: 'admin_info',
        component: () => import("@/views/admin/info/InfoManagementView.vue")
      },
      {
        path: '/admin/food',
        name: 'admin_food',
        component: () => import("@/views/admin/food/FoodManagementView.vue")
      },
      {
        path: '/admin/categories',
        name: 'admin_categories',
        component: () => import("@/views/admin/food/CategoriesManagementView.vue")
      },
      {
        path: '/admin/exceptionRecords',
        name: 'admin_exceptionRecords',
        component: () => import("@/views/admin/order/ExceptionRecordsView.vue")
      },
      {
        path: '/admin/order',
        name: 'admin_order',
        component: () => import("@/views/admin/order/OrderManagementView.vue")
      },
      {
        path: '/admin/kitchen',
        name: 'admin_kitchen',
        component: () => import("@/views/admin/kitchen/KitchenManagementView.vue")
      },
      {
        path: '/admin/feedback',
        name: 'admin_feedback',
        component: () => import("@/views/admin/feedback/FeedbackAndAnalysisView.vue")
      }
    ]
  },

  // ================= 默认路由 =================
  {
    path: '/',
    name: 'default_login',
    component: () => import("@/views/front/auth/LoginView.vue")
  }
]

// 创建路由实例
const router = createRouter({
  history: createWebHistory(),
  routes,
})

export default router